package com.bubblegumproject.ogo.swing.validation;

import javax.swing.text.JTextComponent;

/**
 * Validator that ensures a JTextComponent contains some text.
 *
 * @author Azubuko Obele (buko.obele@gmail.com)
 */
public class TextRequiredValidator extends AbstractValidator {

    public TextRequiredValidator(JTextComponent component) {
        setTarget(component);
    }

    public boolean isValid() {
        return ((JTextComponent) getTarget()).getText().trim().length() > 0;
    }

    public static TextRequiredValidator TextRequired(JTextComponent component) {
        return new TextRequiredValidator(component);
    }
}
